<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>

<head lang="en">
    <meta charset="UTF-8">
    <title>login</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>

    <link rel="stylesheet" href="/Public/AmazeUI-2.4.2/assets/css/amazeui.min.css"/>
    <link href="/Public/css1/dlstyle.css" rel="stylesheet" type="text/css">
    <script src="/Public/AmazeUI-2.4.2/assets/js/jquery.min.js"></script>
    <script src="/Public/AmazeUI-2.4.2/assets/js/amazeui.min.js"></script>
    <script src="/Public/js/layer/layer.js"></script>

</head>

<body>

<div class="login-boxtitle">
    <a href="<?php echo U('Home/Index/index');?>"><img alt="" src="/Public/images1/logoNew.png"/></a>
</div>

<div class="res-banner">
    <div class="res-main" style="margin:0 auto;">
        <div class="login-box" style="background: url('/Public/images1/bg-middle.png') 1262px 0px; ">
            <div class="box" style="margin-top: 150px;">
                <form method="post">
                    <div class="user-email">
                        <label for="email" style="">Account&nbsp;:</label>
                        <input type="email" name="username" id="username" placeholder="Email address or member ID">
                    </div>

                    <div class="user-pass">
                        <label for="password">Password&nbsp;:</label>
                        <input type="password" name="password" id="password" placeholder="Set password">
                    </div>


                </form>

                <div class="am-cf" style="margin-bottom: 20px;margin-top: 30px;">
                    <input type="submit" name="" value="Sign in" class="am-btn am-btn-primary am-btn-sm am-fl" style="background: #2b7ce5;height: 36px;line-height: 10px;font-size: 20px;font-family: Candara;" onclick="checkSubmit()">
                </div>

                <a href="<?php echo U('Home/User/register');?>" style="float: right;display: block;color: #08c;font-size: 20px;font-family: Candara;">Join in</a>

                <script>
                    $(function () {
                        $('#doc-my-tabs').tabs();
                    })
                </script>
            </div>


        </div>
    </div>

    <div class="footer " style="text-align: center" >
        <div class="footer-bd " style="color: #999;" >
            <p>China Contact: Ms.Sophia Gan EMAIL:sophia@sensilintl.com Tel: 0086 15880683346
            USA Contact: Mr.Brian Williams EMAIL:brain@sensilintl.com
                Tel:001 702 308 4860 M: 001 660537 2111 /001 619 5724642</p>
            <p>© 2017-2018 Sensil International INC.</p>
        </div>
    </div>
</div>



<script type="text/javascript">

    function checkSubmit()
    {
        var username = $.trim($('#username').val());
        var password = $.trim($('#password').val());
        var referurl = $('#referurl').val();
//        var verify_code = $.trim($('#verify_code').val());
        if(username == ''){
            showErrorMsg('User Name cannot be empty!');
            return false;
        }
        if(  !checkEmail(username)){
            showErrorMsg('Incorrect mailbox format!');
            return false;
        }
        if(password == ''){
            showErrorMsg('Password cannot be empty!');
            return false;
        }
        /*        if(verify_code == ''){
         showErrorMsg('验证码不能为空!');
         return false;
         }*/

        $.ajax({
            type : 'post',
            url : '/index.php?m=Home&c=User&a=do_login',
            data : {username:username,password:password,referurl:referurl},
            dataType : 'json',
            success : function(res){
                console.info(res);
                if(res.status == 1){
                    window.location.href = res.url;
                }else{
                    showErrorMsg(res.msg);
                    verify();
                }
            },
            error : function(res) {
                console.info(res);
                showErrorMsg('retry');
            }
        })

    }

    function showErrorMsg(msg){
        //$('.msg-err').show();
        //$('.J-errorMsg').html(msg);
//        layer.open({content:msg,time:2});


        alert(msg);
    }


    function checkEmail(str){
        var reg = /^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
        if(reg.test(str)){
            return true;
        }else{
            return false;
        }
    }
</script>
</body>

</html>